package cn.stylefeng.guns.modular.api;

import cn.stylefeng.guns.api.core.util.JwtTokenUtil;
import cn.stylefeng.guns.modular.business.model.params.OrderParam;
import cn.stylefeng.guns.modular.business.model.params.OrderQueryParam;
import cn.stylefeng.guns.modular.business.model.result.OrderResult;
import cn.stylefeng.guns.modular.business.service.OrderService;
import cn.stylefeng.guns.sys.core.util.StringUtils;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 * 订单表控制器
 *
 * @author jwj
 * @Date 2019-07-12 14:20:25
 */
@RestController
@RequestMapping("/order-approve")
public class OrderApproveApi extends BaseController {

    private String apiSign = "pmy2019app";

    @Autowired
    private OrderService orderService;

    /**
     * 审核订单
     * @param orderParam
     * @return
     */
    @ApiOperation("审核订单")
    @PostMapping("/approve")
    public ResponseData approve(@RequestBody OrderParam orderParam) {
        if (!orderParam.getApiSign().equals(apiSign)) {
            return ResponseData.error(700, "错误");
        }
        boolean result = this.orderService.approve(orderParam, orderParam.isApproveStatus());
        if (result) {
            return ResponseData.success();
        }
        return ResponseData.error(505, "操作失败");
    }


}


